package com.example.apple.studytoolbar;

import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentPagerAdapter;
import android.support.v4.view.ViewPager;
import android.support.v7.app.AppCompatActivity;
import android.view.WindowManager;

import java.util.AbstractList;
import java.util.ArrayList;

/**********************************************************************
 *
 *
 * @类名 SecondActivity
 * @包名 com.example.apple.studytoolbar
 * @author 谢晗超
 * @创建日期 2018/7/7
 ***********************************************************************/
public class SecondActivity extends AppCompatActivity {

    private ViewPager vp;
    private ArrayList<Fragment> fragmentList;

    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.second_main);
        fragmentList = new ArrayList<>();
        fragmentList.add(new Fragment1());
        fragmentList.add(new Fragment2());

        vp = findViewById(R.id.vp);
        vp.setAdapter(new ContentPagerAdapter(getSupportFragmentManager()));
    }

    private class ContentPagerAdapter extends FragmentPagerAdapter {
        public ContentPagerAdapter(FragmentManager fm) {
            super(fm);
        }
        @Override
        public Fragment getItem(int position) {
            return fragmentList.get(position);
        }
        @Override
        public int getCount() {
            return fragmentList.size();
        }
    }
}
